package cmpe451.group7.ourcity.dao;

import java.util.Date;
import java.util.List;

import cmpe451.group7.ourcity.entity.Place;
import cmpe451.group7.ourcity.entity.Tag;
import cmpe451.group7.ourcity.entity.User;

/**
 * Interface for place DAO objects.
 * 
 */
public interface PlaceDAO extends GenericDAO<Place> {

	/**
	 * Add a new place with the given values.
	 * 
	 * @param placeName
	 * @param country
	 * @param city
	 * @param likeCount
	 * @param latitude
	 * @param longitude
	 * @param creationDate
	 */
	Place insertNewPlace(String placeName, String country, String city,
			int likeCount, double latitude, double longitude,
			Date creationDate, List<Tag> tags, User user);

	/**
	 * Query the database with the given equality restrictions.
	 * 
	 * Empty or null fields are ignored. Overloaded function is called with
	 * NE,SW parameters set to 0
	 * 
	 * @param placeName
	 * @param country
	 * @param city
	 * @param latitude
	 * @param longitude
	 * @param fromDate
	 * @param toDate
	 * @param tags
	 * @return Returns null for error cases.
	 */
	List<Place> findByRestrictions(String placeName, String country,
			String city, Date fromDate, Date toDate, List<Tag> tags);

	/**
	 * This is used when liking a place
	 * 
	 * @param place
	 * @param liked
	 * @return
	 */
	Place incrementLikeCount(Place place, boolean liked);

	/**
	 * Helper function that is used when searching places.
	 * 
	 * When all coordinates are given 0, coordinates are discarded.
	 * 
	 * @param placeName
	 * @param country
	 * @param city
	 * @param fromDate
	 * @param toDate
	 * @param selectedTags
	 * @param ne_lat
	 * @param ne_lng
	 * @param sw_lat
	 * @param sw_lng
	 * @return
	 */
	List<Place> findByRestrictions(String placeName, String country,
			String city, Date fromDate, Date toDate, List<Tag> selectedTags,
			double ne_lat, double ne_lng, double sw_lat, double sw_lng);

	/**
	 * Find places related to the given tags
	 * 
	 * @param tags
	 * @return
	 */
	List<Place> getRelatedPlaces(List<Tag> tags);

	/**
	 * Find the number of places that the given user is created.
	 * 
	 * @param user
	 * @return
	 */
	int getNumberOfUserPlaces(User user);

}
